//
//  DebugConsole.m
//  iCodeMac
//
//  Created by Andrew Barry on 1/04/09.
//  Copyright 2009 Barry Computer Services. All rights reserved.
//

#import "DebugConsole.h"
#import "ConsoleView.h"

DebugConsole *gSharedConsole;

@implementation DebugConsole
+(DebugConsole *) sharedConsole {
	if (gSharedConsole == nil)
		gSharedConsole = [DebugConsole new];
	return gSharedConsole;
}

+(void)logMessage: (NSString *) message {
	[[DebugConsole sharedConsole] log: message];
}

-(void)log: (NSString *) message {
	if (window == nil)
		[self show];
	[text appendLine: message];
}

-(void) show {
	if (window == nil) {
		[NSBundle loadNibNamed:@"Console" owner:self];
		[window setFrameAutosaveName: @"icmDebugConsole"];
	}
	[window orderFront:self];
}

- (void)windowWillClose:(NSNotification *)notification {
	window = nil;
}

@end
